package com.authine.cloudpivot.ext.vo;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 订单商品VO
 *
 * @author 张磊
 * @date 2019年4月15日20:11:59
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("订单商品VO")
public class V2OrderGoodsPutVO implements Serializable {
    @ApiModelProperty(value = "订单商品Id")
    private String id;
    @ApiModelProperty(value = "商品来源类型 2 固买商城，3 单次采购, 3 循环采购")
    private String src;
    @ApiModelProperty(value = "外部来源订单商品id")
    private String clientOrderGoodsId;
    @ApiModelProperty(value = "供应商Id")
    private String vendorId;
    @ApiModelProperty(value = "商品名称")
    private String name;
    @ApiModelProperty(value = "品牌")
    private String brand;
    @ApiModelProperty(value = "型号")
    private String model;
    @ApiModelProperty(value = "规格")
    private String spec;
    @ApiModelProperty(value = "数量")
    private BigDecimal num;
    @ApiModelProperty(value = "单位")
    private String unit;
    @ApiModelProperty(value = "包装数量")
    private BigDecimal packageNum;
    @ApiModelProperty(value = "包装单位")
    private String packageUnit;
    @ApiModelProperty(value = "货期")
    private Integer delivery;
    @ApiModelProperty(value = "金惠编码")
    private String goldenTax;
    @ApiModelProperty(value = "税率")
    private BigDecimal taxRate;
    @ApiModelProperty(value = "运费税率")
    private BigDecimal taxRateFreight;
    @ApiModelProperty(value = "税前商品单价")
    private BigDecimal pretaxPrice;
    @ApiModelProperty(value = "税后商品单价")
    private BigDecimal price;
    @ApiModelProperty(value = "税前运费")
    private BigDecimal pretaxFreight;
    @ApiModelProperty(value = "税后商品运费共计")
    private BigDecimal amount;
    @ApiModelProperty(value = "备注")
    private String memo;
    @ApiModelProperty(value = "订单商品状态")
    private String goodsStatus;
    @ApiModelProperty(value = "图片")
    private String images;
    /**
     * 订单信息
     */
    @ApiModelProperty("下单人名称")
    private String memberName;
    @ApiModelProperty("下单人id")
    private String memberId;
    @ApiModelProperty("客户订单状态")
    private String statusEnum;
    @ApiModelProperty("供应商订单状态")
    private String status;
    @ApiModelProperty("供应商名称")
    private String vendorUserName;
    @ApiModelProperty("联系人")
    private String receiver;
    @ApiModelProperty("联系人电话")
    private String phone;
    @ApiModelProperty("邮编")
    private String postal;
    @ApiModelProperty("详细地址")
    private String address;
    @ApiModelProperty("组织名称")
    private String orgName;
    /**
     * 客户订单信息
     */
    @ApiModelProperty("下单时间")
    private Date time;
    @ApiModelProperty("客户订单ID")
    private String customerId;
    @ApiModelProperty("供应商订单ID")
    private String vendorOrderId;

    @ApiModelProperty("erpPO")
    private String erpPO;
    @ApiModelProperty("税前商品合计")
    private BigDecimal pretaxTotal;
    @ApiModelProperty("税后商品合计")
    private BigDecimal total;
    @ApiModelProperty("运费")
    private BigDecimal freight;
    @ApiModelProperty("税前商品运费共计")
    private BigDecimal pretaxAmount;
    @ApiModelProperty("收货单附件")
    private String attachment;
    @ApiModelProperty("订单来源")
    private String orderType;
    @ApiModelProperty("分类")
    private String category;
    @ApiModelProperty("需求部门")
    private String demandDeptName;
    @ApiModelProperty("询价人")
    private String inquiryMemberName;
    @ApiModelProperty("标记信息")
    private String remarkMessages;
    @ApiModelProperty(hidden = true)
    private String quotationGoodsId;
    @ApiModelProperty(value = "成本中心")
    private String costCenterName;

//    public static V2OrderGoodsPutVO toV2OrderGoodsPutVO(OrderGoodsEntity o) {
//        VendorOrderEntity v = o.getVendorOrder();
//        if (v == null) {
//            v = new VendorOrderEntity();
//        }
//        return new V2OrderGoodsPutVO(o.getId(), o.getCartSrc().id, o.getClientOrderGoodsId(),
//                o.getVendorId(), o.getName(), o.getBrand(), o.getModel(), o.getSpec(),
//                o.getNum(), o.getUnit(), o.getPackageNum(), o.getPackageUnit(), o.getDelivery(),
//                o.getGoldenTax(), o.getTaxRate(), o.getTaxRateFreight(), o.getPretaxPrice(),
//                o.getPrice(), o.getPretaxFreight(), o.getAmount(), o.getMemo(), o.getStatus() == null ? null : o.getStatus().text,
//                v.getCustomerMemName(),o.getModifiedBy(), v.getCustomerMemId(), v.getStatusEnum() == null ? null : v.getStatusEnum().text,
//                v.getStatus().getText(), v.getUsername(), v.getReceiver(), v.getPhone(), v.getPostal(), v.getAddress(), v.getOrganizationName(),
//                v.getCustomerOrder().getTime(), v.getCustomerOrder() == null ? null : v.getCustomerOrder().getId(),v.getId(), o.getErpPO(),
//                o.getPretaxTotal(), o.getTotal(), o.getFreight(), o.getPretaxAmount(), o.getAttachment(),
//                Optional.ofNullable(v.getCustomerOrder()).map(e->e.getOrderType().text).orElse(null), o.getCategory(),
//                null, null, o.getRemarkMessages(), Optional.ofNullable(o.getQuotationGoodsId()).map(Integer::longValue).orElse(null), null);
//    }
//
//    public static List<V2OrderGoodsPutVO> toV2OrderGoodsPutVOs(List<OrderGoodsEntity> os) {
//        List<V2OrderGoodsPutVO> ovs = new ArrayList<>();
//        if (os != null && !os.isEmpty()) {
//            os.forEach(o -> {
//                VendorOrderEntity v = o.getVendorOrder();
//                ovs.add(new V2OrderGoodsPutVO(o.getId(), o.getCartSrc().id, o.getClientOrderGoodsId(),
//                        o.getVendorId(), o.getName(), o.getBrand(), o.getModel(), o.getSpec(),
//                        o.getNum(), o.getUnit(), o.getPackageNum(), o.getPackageUnit(), o.getDelivery(),
//                        o.getGoldenTax(), o.getTaxRate(), o.getTaxRateFreight(), o.getPretaxPrice(),
//                        o.getPrice(), o.getPretaxFreight(), o.getAmount(), o.getMemo(), o.getStatus() == null ? null : o.getStatus().text, v.getCustomerMemName(),o.getModifiedBy(),
//                        v.getCustomerMemId(), v.getStatusEnum() == null ? null : v.getStatusEnum().text, v.getStatus().getText(),
//                        v.getUsername(), v.getReceiver(), v.getPhone(), v.getPostal(), v.getAddress(), v.getOrganizationName(),
//                        v.getCustomerOrder().getTime(), v.getCustomerOrder() == null ? null : v.getCustomerOrder().getId(),v.getId(), o.getErpPO(),
//                        o.getPretaxTotal(), o.getTotal(), o.getFreight(), o.getPretaxAmount(), o.getAttachment(),
//                        Optional.ofNullable(v.getCustomerOrder()).map(e->e.getOrderType().text).orElse(null), o.getCategory(),
//                        null, null, null, null, null));
//            });
//        }
//        return ovs;
//    }
}
